//
//  SXTLandingViewController.m
//  SXT
//
//  Created by gaochar on 2017/3/18.
//  Copyright © 2017年 so. All rights reserved.
//

#import "SXTLandingViewController.h"

@interface SXTLandingViewController () <UITextFieldDelegate>

/**
 提示label
 */
@property (nonatomic, strong) UILabel *tostLabel;

/**
 手机号text
 */
@property (nonatomic, strong) UITextField *userNameText;

/**
 密码text
 */
@property (nonatomic, strong) UITextField *passwordText;

/**
 下一步按钮
 */
@property (nonatomic, strong) UIButton *nextBtn;

/**
 去登陆
 */
@property (nonatomic, strong) UIButton *goLoginBtn;

/**
 qq登陆按钮
 */
@property (nonatomic, strong) UIButton *qqLoginBtn;

/**
 微信登陆按钮
 */
@property (nonatomic, strong) UIButton *WXLoginBtn;

/**
 新浪登陆按钮
 */
@property (nonatomic, strong) UIButton *sinaLoginBtn;

/**
 一键登陆
 */
@property (nonatomic, strong) UILabel *oneLogin;

/**
 分割线
 */
@property (nonatomic, strong) UILabel *lineLabel;

/**
 输入框背景图
 */
@property (nonatomic, strong) UILabel *textBackLabel;

/**
 text中间分割线
 */
@property (nonatomic, strong) UILabel *textLineLabel;

@end

@implementation SXTLandingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = MainColor;
    self.edgesForExtendedLayout = 0;
    
    [self.view addSubview:self.tostLabel];
    [self.view addSubview:self.textBackLabel];
    [self.view addSubview:self.userNameText];
    [self.view addSubview:self.passwordText];
    [self.view addSubview:self.textLineLabel];
    [self.view addSubview:self.nextBtn];
    [self.view addSubview:self.goLoginBtn];
    [self.view addSubview:self.lineLabel];
    [self.view addSubview:self.oneLogin];
    [self.view addSubview:self.qqLoginBtn];
    [self.view addSubview:self.WXLoginBtn];
    [self.view addSubview:self.sinaLoginBtn];
    
    __weak typeof(self) weakSelf = self;
    
    [_tostLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@35);
        make.top.right.equalTo(weakSelf.view);
        make.left.equalTo(weakSelf.view.mas_left).offset(15);
    }];
    
    [_textBackLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo (@89);
        make.top.equalTo(weakSelf.tostLabel.mas_bottom);
        make.left.equalTo(weakSelf.view.mas_left).offset(-1);
        make.right.equalTo(weakSelf.view.mas_right).offset(1);
    }];
    
    [_userNameText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf.view).offset(15);
        make.height.equalTo(@44);
        make.top.equalTo(weakSelf.textBackLabel.mas_top);
    }];
    
    [_passwordText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf.view).offset(15);
        make.height.equalTo(@44);
        make.top.equalTo(weakSelf.userNameText.mas_bottom).offset(1);
    }];
    
    [_textLineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@1);
        make.left.equalTo(weakSelf.textBackLabel.mas_left).offset(15);
        make.right.equalTo(weakSelf.textBackLabel.mas_right).offset(-15);
        make.centerY.equalTo(weakSelf.textBackLabel.mas_centerY);
    }];
    
    [_nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.view.mas_left).offset(16);
        make.right.equalTo(weakSelf.view.mas_right).offset(-16);
        make.height.equalTo(@35);
        make.top.equalTo(weakSelf.passwordText.mas_bottom).offset(15);
    }];
    
    [_goLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(70, 16));
        make.right.equalTo(weakSelf.view.mas_right).offset(-15);
        make.top.equalTo(weakSelf.nextBtn.mas_bottom).offset(23);
    }];
    
    [_oneLogin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 20));
        make.centerX.equalTo(weakSelf.view.mas_centerX);
        make.top.equalTo(weakSelf.nextBtn.mas_bottom).offset(57);
    }];
    
    [_WXLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.oneLogin.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(45, 45));
        make.centerX.equalTo(weakSelf.view.mas_centerX);
    }];
    
    [_qqLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.oneLogin.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(45, 45));
        make.right.equalTo(weakSelf.WXLoginBtn.mas_left).offset(-(VIEW_WIDTH - 135) / 4);
        
    }];
    
    [_sinaLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.oneLogin.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(45, 45));
        make.left.equalTo(weakSelf.WXLoginBtn.mas_right).offset((VIEW_WIDTH - 135) / 4);
    }];
    
    [_lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.oneLogin.mas_centerY);
        make.height.equalTo(@1);
        make.left.equalTo(weakSelf.view.mas_left).offset(16);
        make.right.equalTo(weakSelf.view.mas_right).offset(-16);
    }];
}

- (UILabel *)tostLabel {
    if (!_tostLabel) {
        _tostLabel = [[UILabel alloc] init];
        _tostLabel.text = @"请输入手机号码注册新用户";
        _tostLabel.font = [UIFont systemFontOfSize:14.0];
        _tostLabel.textColor = RGB(81, 81, 81);
    }
    return _tostLabel;
}

- (UILabel *)textBackLabel {
    if (!_textBackLabel) {
        _textBackLabel = [[UILabel alloc] init];
        _textBackLabel.backgroundColor = [UIColor whiteColor];
        _textBackLabel.layer.borderWidth = 1;
        _textBackLabel.layer.borderColor = RGB(188, 188, 188).CGColor;
    }
    return _textBackLabel;
}

- (UITextField *)userNameText {
    if (!_userNameText) {
        _userNameText = [[UITextField alloc] init];
        _userNameText.delegate = self;
        _userNameText.placeholder = @"请输入手机号码";
    }
    return _userNameText;
}

- (UITextField *)passwordText {
    if (!_passwordText) {
        _passwordText = [[UITextField alloc] init];
        _passwordText.delegate = self;
        _passwordText.placeholder = @"设置账号密码";
    }
    return _passwordText;
}

- (UILabel *)textLineLabel {
    if (!_textLineLabel) {
        _textLineLabel = [[UILabel alloc] init];
        _textLineLabel.backgroundColor = RGB(188, 188, 188);
    }
    return _textLineLabel;
}

- (UIButton *)nextBtn {
    if (!_nextBtn) {
        _nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
        _nextBtn.backgroundColor = RGB(229, 229, 229);
        [_nextBtn setTitleColor:RGB(132, 132, 1321) forState:UIControlStateNormal];
    }
    return _nextBtn;
}

- (UIButton *)goLoginBtn {
    if (!_goLoginBtn) {
        _goLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_goLoginBtn setTitle:@"去登录" forState:UIControlStateNormal];
        [_goLoginBtn setTitleColor:RGB(56, 145, 241) forState:UIControlStateNormal];
        _goLoginBtn.backgroundColor = MainColor;
    }
    return _goLoginBtn;
}

- (UILabel *)oneLogin {
    if (!_oneLogin) {
        _oneLogin = [[UILabel alloc] init];
        _oneLogin.text = @"一键登录";
        _oneLogin.textColor = RGB(190, 190, 190);
        _oneLogin.backgroundColor = MainColor;
        _oneLogin.textAlignment = NSTextAlignmentCenter;
        _oneLogin.font = [UIFont systemFontOfSize:16.0];
    }
    return _oneLogin;
}

- (UIButton *)qqLoginBtn {
    if (!_qqLoginBtn) {
        _qqLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_qqLoginBtn setImage:[UIImage imageNamed:@"登录界面qq登录"] forState:UIControlStateNormal];
    }
    return _qqLoginBtn;
}

- (UIButton *)WXLoginBtn {
    if (!_WXLoginBtn) {
        _WXLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_WXLoginBtn setImage:[UIImage imageNamed:@"登录界面微信登录"] forState:UIControlStateNormal];
    }
    return _WXLoginBtn;
}

- (UIButton *)sinaLoginBtn {
    if (!_sinaLoginBtn) {
        _sinaLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_sinaLoginBtn setImage:[UIImage imageNamed:@"登录界面微博登录"] forState:UIControlStateNormal];
    }
    return _sinaLoginBtn;
}

- (UILabel *)lineLabel {
    if (!_lineLabel) {
        _lineLabel = [[UILabel alloc] init];
        _lineLabel.backgroundColor = RGB(190, 190, 190);
    }
    return _lineLabel;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
